import path from 'path';
import fs from 'fs';

export default (instruction: 'force' | 'alter') => {
  fs.readdirSync(path.resolve('./src/model/mysql')).forEach((file) => {
    if (instruction === 'force') {
      require(path.resolve(`./src/model/mysql/${file}`)).default.sync({ force: true });
    } else if (instruction === 'alter') {
      require(path.resolve(`./src/model/mysql/${file}`)).default.sync({ alter: true });
    }
  });
};
